﻿<style>
    .pt20 {
        padding-top: 0px;
    }

    .jg-right {
        padding-top: 20px;
    }
    /*.main-content {
    clear:both;
    display:table;
    content:""
    }*/
</style>
<div ms-controller="YGINDEX">
    <div class="jg-left pull-left ft14">
        <p class="mb10 ft16 padding20 c999" style="border-bottom:1px solid #e5e5e5;"><i class="iconfont icon-zuzhi ft14 mr5"></i>组织机构</p>
        <script type="avalon" id="tmpltree">
            <li ms-repeat-branch="branch.ChildBranch">
                <div class="jg-item" ms-class-1="active:branch.DeptCode==SelDeptItem.DeptCode">
                    <b ms-click="BranchClick(branch,$event)">
                        <i class="caret" ms-click="BranchToggle(this,$event)" ms-class-1="active:branch.ChildBranch.size()>0"></i>
                        <span class="jg-name">{{branch.DeptName}}</span>
                    </b>
                    <div class="jg-sz">
                        <span class="iconfont icon-dayin" ms-click="OpenPrint(branch,$event)"></span>
                    </div>
                </div>
                <ul class="children-list" ms-include="'tmpltree'"></ul>
            </li>
        </script>
        <ul class="jg-list-box">
            <li ms-repeat-branch="BranchListData">
                <div class="jg-item" ms-class-1="active:branch.DeptCode==SelDeptItem.DeptCode">
                    <b ms-click="BranchClick(branch,$event)">
                        <i class="caret" ms-click="BranchToggle(this,$event)" ms-class-1="active:branch.ChildBranch.size()>0"></i>
                        <span class="jg-name">{{branch.DeptName}}</span>
                    </b>
                    <div class="jg-sz">
                        <span class="iconfont icon-dayin" ms-click="OpenPrint(branch,$event)"></span>
                    </div>
                </div>
                <ul class="children-list" ms-include="'tmpltree'"></ul>
            </li>
        </ul>
    </div>
    <div class="jg-right ">
        <!-- 机构管理详情 -->
        <div class="jg-cont ft14">
            <div class=" ml15" style="position:relative">
                <a class="c-default dropdown-toggle ft16">
                    {{SelDeptItem.DeptName}}
                </a>
            </div>
            <div class="detail-con">
                <div class="detail-item" ms-if="SelDeptItem.DeptDesc">
                    <span class="item-tit">部门描述：</span>
                    <div class="item-con">{{SelDeptItem.DeptDesc}}</div>
                </div>
                <div class="detail-item" ms-if="SelDeptItem.BranchLeader">
                    <span class="item-tit">部门负责人：</span>
                    <div class="item-con">{{SelDeptItem.BranchLeader?ComFunJS.convertuser(SelDeptItem.BranchLeader):""}}</div>
                </div>
                <div class="detail-item" ms-if="SelDeptItem.RoomCode">
                    <span class="item-tit">房间号：</span>
                    <div class="item-con">{{SelDeptItem.RoomCode}}</div>
                </div>
            </div>
        </div>
        <div class="default-tab ft14">
            <div class="ml15 pb20 mr15 oh">  
                <button type="button" class="btn btn-info" style="float:right" data-toggle="modal" data-target="#myselfModal">自定义显示</button>
                <div class="input-group ml15" style="width:295px;float: right;margin-right: 20px;">
                    <input type="search" class="form-control" placeholder="搜索姓名，账号，部门，手机号" ms-duplex="searchContent">
                    <span class="input-group-addon" ms-click="GetUserList()">搜索</span>
                </div>
            </div>  
            <div class="default-tab ft14 pt20 table-responsive">
                <table class="table table-striped  table-hover">
                    <thead>
                        <tr>
                            <th></th>
                            <th>姓名</th>
                            <th ms-repeat-im="ShowColumns" ms-visible="im.IsSel">{{im.ColText}}</th>
                        </tr>
                    </thead>
                    <tbody>
                        <tr ms-repeat-item="UserData">
                            <td></td>
                            <td ms-click="ViewForm('XTGL_YGGL',item.UserName,'',$event)" class="lk">
                                <span ms-if="item.IsUse=='N'" class="ico-radius-r"></span>
                                <span ms-if="item.IsUse=='Y'" class="ico-radius-r color-greed"></span>{{item.UserRealName}}
                            </td>

                            <td ms-repeat-im="ShowColumns" style="min-width:120px;" ms-visible="im.IsSel" >{{ComFunJS.FnFormat(item[im.ColName],im)|html}}</td>
                        </tr>
                    </tbody>
                    <tfoot>
                        <tr ms-if="isnull"><td class="tc"></td><td>暂无数据</td></tr>
                    </tfoot>
                </table>
                </div>
                <div class="ui-datatable-page ft14 pl20">
                    <div ms-if="UserData.size() !=0"><span class="ico-radius-r"></span>禁止登陆</div>
                    <div ms-if="UserData.size() !=0"><span class="ico-radius-r color-red"></span>未激活</div>
                    <div ms-if="UserData.size() !=0"><span class="ico-radius-r color-greed"></span>正常</div>
                    <div id="pageDiv" ms-visible="model.page.total>model.pageNum[0].num" class="pull-right"></div>
                    <div class="pull-right" ms-visible="UserData.size()!=0">
                        <span>共{{model.page.total}}条记录</span>
                        <span ms-visible="model.page.total>model.pageNum[0].num">
                            选择每页条数
                            <select style="height: 25px; width: 50px;" ms-change="selNum(this.value)" ms-duplex="model.page.pagecount">
                                <option ms-repeat-pg="pageNum" ms-attr-value="pg.num" ms-attr-selected="pg.num==model.page.pagecount?'selected':''">{{pg.num}}</option>
                            </select>
                        </span>
                    </div>
                </div>

            </div>
    </div>
</div>
<script type="text/javascript">
    var tempindex = avalon.define({
        $id: "YGINDEX",
        BranchListData: [],
        UserData: [],
        searchContent: "",
        SelDeptItem: {},
        selNum: function (item) {    //选择显示的条数
            model.page.pagecount = item;
            tempindex.GetUserList();
        },
        InitWigetData: function () {
            model.ShowColumns.clear();
            model.ShowColumns.pushArray([
                { "ColName": "DeptName", "ColText": "部门", "IsSel": true, "format": "text" },
                { "ColName": "zhiwu", "ColText": "职务", "IsSel": true, "format": "text" },
                { "ColName": "mobphone", "ColText": "手机", "IsSel": true, "format": "text" },
                { "ColName": "isgz", "ColText": "关注状态", "IsSel": false, "format": "gzstatus" },
                { "ColName": "telphone", "ColText": "座机", "IsSel": false, "format": "text" },
                { "ColName": "mailbox", "ColText": "邮箱", "IsSel": false, "format": "text" },
                { "ColName": "RoomCode", "ColText": "房间号", "IsSel": false, "format": "text" },
                { "ColName": "Usersign", "ColText": "职责", "IsSel": false, "format": "text", "len": 15 },
                { "ColName": "Sex", "ColText": "性别", "IsSel": false, "format": "text" },
                { "ColName": "weixinCard", "ColText": "微信号", "IsSel": false, "format": "text" },
                { "ColName": "NickName", "ColText": "昵称", "IsSel": false, "format": "text" },
                { "ColName": "JobNum", "ColText": "工号", "IsSel": false, "format": "text" },
                { "ColName": "QQ", "ColText": "QQ", "IsSel": false, "format": "text" },
                { "ColName": "IDCard", "ColText": "身份证", "IsSel": false, "format": "text" },
                { "ColName": "Nationality", "ColText": "籍贯", "IsSel": false, "format": "text" },
                { "ColName": "Nation", "ColText": "民族", "IsSel": false, "format": "text" },
                { "ColName": "HomeAddress", "ColText": "家庭住址", "IsSel": false, "format": "text" },
                { "ColName": "GSPhone", "ColText": "公司电话", "IsSel": false, "format": "text" },
                { "ColName": "EntryDate", "ColText": "入职时间", "IsSel": false, "format": "dateformat" },
                { "ColName": "DepartureDate", "ColText": "离职时间", "IsSel": false, "format": "dateformat" },
                { "ColName": "Birthday", "ColText": "生日", "IsSel": false, "format": "dateformat" },
                { "ColName": "Marriage", "ColText": "婚姻状况", "IsSel": false, "format": "text" },
                { "ColName": "Children", "ColText": "子女", "IsSel": false, "format": "text" },
                { "ColName": "JJLXR", "ColText": "紧急联系人", "IsSel": false, "format": "text" },
                { "ColName": "JJLXRDH", "ColText": "紧急联系人电话", "IsSel": false, "format": "text" },
                { "ColName": "Hire", "ColText": "雇佣方式", "IsSel": false, "format": "text" },
                { "ColName": "ZZTime", "ColText": "转正时间", "IsSel": false, "format": "dateformat" },
                { "ColName": "ContractSTime", "ColText": "劳动合同开始时间", "IsSel": false, "format": "dateformat" },
                { "ColName": "ContractETime", "ColText": "劳动合同结束时间", "IsSel": false, "format": "dateformat" },
                { "ColName": "SocialInsurance", "ColText": "社保号码", "IsSel": false, "format": "text" },
                { "ColName": "GJJID", "ColText": "公积金账号", "IsSel": false, "format": "text" },
                { "ColName": "BankCard", "ColText": "银行卡号", "IsSel": false, "format": "text" },
                { "ColName": "BankName", "ColText": "银行名称", "IsSel": false, "format": "text" },
            ]);
            tempindex.GetBranch();
            ComFunJS.initForm();
        }, GetUserList: function () {
            $.getJSON('/API/VIEWAPI.ashx?Action=XTGL_GETUSERBYCODENEW_PAGE', { "P1": tempindex.SelDeptItem.DeptCode, P2: tempindex.searchContent, pagecount: model.page.pagecount, p: 1 }, function (resultData) {
                if (resultData.ErrorMsg == "") {
                    tempindex.UserData = resultData.Result;
                    model.page.total = resultData.Result2;
                    if (tempindex.UserData.size() == 0) { model.isnull = true; } else { model.isnull = false; }
                    tempindex.totalUserCount = resultData.Result2;
                    var page = 1;
                    laypage({
                        cont: 'pageDiv', //容器。值支持id名、原生dom对象，jquery对象。
                        //    pages: resultData.Result1, //通过后台拿到的总页数
                        pages: Math.ceil(parseInt(resultData.Result2) * 1.0 / model.page.pagecount), //通过后台拿到的总页数
                        curr: 1, //初始化当前页
                        skin: 'molv',
                        jump: function (e) { //触发分页后的回调
                            if (e.curr != page) {
                                $.getJSON('/API/VIEWAPI.ashx?Action=XTGL_GETUSERBYCODENEW_PAGE', { "P1": tempindex.SelDeptItem.DeptCode, P2: tempindex.searchContent, pagecount: model.page.pagecount, p: e.curr }, function (resultData) {
                                    tempindex.UserData = resultData.Result;
                                    tempindex.totalUserCount = resultData.Result2;
                                })
                                page = e.curr;
                            }
                        }
                    });
                }
            })
        },
        GetBranch: function () {
            $.getJSON('/API/VIEWAPI.ashx?Action=XTGL_GETALLBMNEW',{}, function (resultData) {
                tempindex.BranchListData = resultData.Result;
                tempindex.SelDeptItem = resultData.Result[0];
                tempindex.GetUserList();
            })
        }, BranchToggle: function (dom, event) {
            if (event) {
                event.stopPropagation();
            }
            if (dom) {
                $(".jg-item b i").removeClass("active");
                if ($(dom).parent().parent().next(".children-list").css("display") == "none") {
                    $(dom).addClass("active");
                }
                $(dom).parent().parent().next(".children-list").slideToggle('fast');

            }
        }, BranchClick: function (item, event) {
            if (event) {
                event.stopPropagation();
            }
            tempindex.SelDeptItem = {};
            tempindex.SelDeptItem = item.$model;
            tempindex.GetUserList();

        }, OpenPrint: function (item, event) {
            if (event) {
                event.stopPropagation();
            }
            top.ComFunJS.winviewform("/ViewV5/AppPage/TXL/TXLPrint.html?branchId=" + item.DeptCode, "数据打印", "1000", "");
        }, GetWXStatus: function (s) {
            var statusName = "";
            //关注状态: 1 = 已关注，2 = 已禁用，4 = 未关注
            switch (s) {
                case "1":
                    statusName = "已关注";
                    break;
                case "2":
                    statusName = "已禁用";
                    break;
                case "4":
                    statusName = "<span style='color:red'>未关注</span>";
                    break;
                default:
                    statusName = "<span style='color:red'>未关注</span>";
                    break;
            }
            return statusName;
        }
    });

    function jptj(event) {
        if (event.keyCode == 13 || event.keyCode == 10) {
            tempindex.GetUserList();
        }
    }//# sourceURL=YGINDEX.js;
</script>